package com.tougutips.auth.utils;

import com.github.qcloudsms.SmsSingleSender;
import org.json.JSONException;

import javax.xml.ws.http.HTTPException;
import java.io.IOException;

public final class SmsUtils {
    private static int APP_ID = 1400677657;
    private static String APP_KEY = "5078cd8cc5b8c3e3763f9b4d33ed5c7d";
    private static int TEMPLATE_ID = 1398314;
    private static String SMS_SIGN = "开发小伙的铁匠铺";
    private static String NATION_CODE = "86";

    public static void send(String code, String phoneNum, int minTime) {
        try {
            String[] params = {code, Integer.toString(minTime)};
            SmsSingleSender ssender = new SmsSingleSender(APP_ID, APP_KEY);
            ssender.sendWithParam(NATION_CODE, phoneNum, TEMPLATE_ID, params, SMS_SIGN, "", "");
        } catch (HTTPException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (com.github.qcloudsms.httpclient.HTTPException e) {
            e.printStackTrace();
        }
    }
}
